package com.example.administrator.nurse.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;

import com.example.administrator.nurse.R;
import com.example.administrator.nurse.fragment.FeatureRecodeFragment;

/**
 * Created by Administrator on 2016/5/8.
 */

public class ItemRadio {
    private View itemRadio;
    public ItemRadio(Context context,LinearLayout parent){
        itemRadio= LayoutInflater.from(context).inflate(R.layout.radio_item,parent,false);
    }
    public ItemRadio withImageDrawable(int drawableId){
        ((RadioButton)itemRadio.findViewById(R.id.radio)).setBackgroundResource(drawableId);
        return this;
    }
    public ItemRadio withTvText(String str){
        ((TextView)itemRadio.findViewById(R.id.text)).setText(str);
        return this;
    }

    /** 如有必要，动态设置大小 */
    public ItemRadio withLayoutParam(ViewGroup.LayoutParams lp){
        itemRadio.setLayoutParams(lp);
        return this;
    }

    public ItemRadio withRadioChangeListener(FeatureRecodeFragment.checkListener changeListener){
        ((RadioButton)itemRadio.findViewById(R.id.radio)).setOnCheckedChangeListener(changeListener);
        return this;
    }

    public View init(){
        return itemRadio;
    }
}
